<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
		<link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" />
	</head>

	<body>
		<div class="layui-container">
			<h1>规则管理</h1>
			<a href="/">回到首页</a>
		
			<a href="/droolsRule/form" class="layui-btn layui-btn-sm"><i class="layui-icon">&#xe608;</i> 添加</a>
			<table id="demo" lay-filter="test"></table>
			
		</div>

		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
		  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
		  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->
		<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
		<script src="https://www.layuicdn.com/layui/layui.js"></script>
		
		<!--您的Layui代码start-->
		<script type="text/javascript" th:inline="none">
			layui.use(['layer', 'table', 'form', 'laydate', 'element', 'upload'], function() {
				var layer = layui.layer,
					table = layui.table,
					form = layui.form,
					laydate = layui.laydate,
					element = layui.element,
					upload = layui.upload;

				/*layer弹出一个示例*/
				//layer.msg('Hello World');
				
				//第一个实例
				  table.render({
				    elem: '#demo'
				    ,height: 462
				    ,url: '/droolsRule/page' //数据接口
				    ,page: true //开启分页
				    ,parseData: function(res){ //res 即为原始返回的数据
				        return {
				          "code": res.code, //解析接口状态
				          "msg": res.message, //解析提示文本
				          "count": res.data.total, //解析数据长度
				          "data": res.data.records //解析数据列表
				        }
				    }
				    ,cols: [[ //表头
				      {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left'}
				      ,{field: 'ruleFor', title: '业务场景', width:150}
				      ,{field: 'drlContent', title: '规则内容'}
				      ,{fixed: 'right', title:'操作', width:120, templet: function(d){
				    	  let edit = '<a class="layui-btn layui-btn-xs" href="/droolsRule/form?id=' + d.id + '">编辑</a>';
				    	  let remove = '<a class="layui-btn layui-btn-xs layui-btn-danger" href="/droolsRule/remove?id=' + d.id + '">删除</a>';
				          return edit+remove;
				      }}
				    ]]
				  });
			});
		</script>
	</body>
</html>